import React from 'react';
import { history } from 'umi'
import { Radio, Tooltip, Button } from 'antd';
import classNames from 'classnames';

import AuthComponent from '@/utils/auth/AuthComponent';
import { postponeNextMonth, salaryRecheck, hrRecheck } from '@/services/salaryManage/salaryCalculate';
import { goToSalaryRecheckLog } from '@/pages/SalaryManage/utils/pageNavigateUtil';
import salaryStyles from '@/pages/SalaryManage/salaryManage.less';
import BaseRecheckModel from '../BaseRecheckModel';

const {
    latestSalaryYearMonth,
    queryTableBodyData,
    queryTableHeadData,
    queryItemCheckWarn,
    sendSalaryPayroll,
    applyPayment,
    approveSubmit,
    getSalaryPayrollItems,
    getLastSysOperationSearchInfo,
    excelExport
} = salaryRecheck;

const { getCheckButtons, passCheckBatch, updateData, reject, cancelCheck, passCheck } = hrRecheck;

const hrRecheckModel = BaseRecheckModel('hrRecheckModel', {
    latestSalaryYearMonth,
    getCheckButtons,
    getLastSysOperationSearchInfo,
    queryTableBodyData,
    queryTableHeadData,
    queryItemCheckWarn,
    sendSalaryPayroll,
    applyPayment,
    approveSubmit,
    passCheckBatch,
    updateData,
    postponeNextMonth,
    excelExport,
    getSalaryPayrollItems,
    reject,
    cancelCheck,
    passCheck
});
// 代表HR复核
hrRecheckModel.state.nodeCode = 3;
hrRecheckModel.state.RecheckMenuRight = ({ searchModel }) => {
    const goToOverview = () => {
        history.push({
            pathname: '/finance/salary/calculate/recheck/hrrecheck'
        });
    }

    const { organizationCode } = searchModel

    return (
        <div>
            <Radio.Group className={classNames(salaryStyles.switchRadio, salaryStyles.mr8)} value="detail">
                <AuthComponent code="finance:salary:computation:check:hrcollect">
                    <Tooltip title="总览">
                        <Radio.Button value="overView" onClick={goToOverview}>
                            <i className="icon iconfont iconzonglan" />
                        </Radio.Button>
                    </Tooltip>
                </AuthComponent>
                <AuthComponent code="finance:salary:computation:check:hrdetail">
                    <Tooltip title="详细">
                        <Radio.Button value="detail">
                            <i className="icon iconfont iconxiangxi" />
                        </Radio.Button>
                    </Tooltip>
                </AuthComponent>
            </Radio.Group>
            <Button onClick={() => goToSalaryRecheckLog(organizationCode)}>操作日志</Button>
        </div>
    );
}

export default hrRecheckModel;
